package com.rankeiot.platform.service;

import com.rankeiot.core.data.response.Resp;
import lombok.Data;
import org.springframework.http.ResponseEntity;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public interface IFileStoreService {
    @Data
    class FileInfo{
        private String path;
        private String name;
        private long size;
        private long lastModify;
        private String type;
        public FileInfo(){

        }

        public FileInfo(String name, long size, long lastModify, String type) {
            this.name = name;
            this.size = size;
            this.lastModify = lastModify;
            this.type = type;
        }

    }
    Resp<String> save(InputStream file,String fileName,String user) throws IOException;
    //保存文件，返回路径
   default Resp<String> save(MultipartFile file,String user) throws IOException{
     return save(file.getInputStream(), file.getOriginalFilename(), user);
   }
    Resp delete(String path,String user);

    ResponseEntity getFile(String path,String query);
    default String getFullPath(String path,String prefix){
        return prefix+path;
    }
    List<FileInfo> list(String path);
   default Map<String, String> policy(String fileName, String user){
        return new HashMap<>();
   }
}
